#include<stdio.h>
#include<unistd.h>

#include<us100.h>
#include<gpiox.h>

#define INIT_PIN_GROUP  GPIOD
#define INIT_PIN_NUM    17

#define BACK_PIN_GROUP  GPIOD
#define BACK_PIN_NUM    21

#define DETECT_TIMES 30

int height;

int main(int argc, char **argv) {
    int i;  /* common counter */

    gpio_init();


    for(i = 0; i < DETECT_TIMES; i++) {
        us100(INIT_PIN_GROUP, INIT_PIN_NUM,
                BACK_PIN_GROUP, BACK_PIN_NUM, &height);
        printf("distance is %dcm\n", height);

        // us100_back(BACK_PIN_GROUP, BACK_PIN_NUM, NULL);
        // printf("distance is %lfm\n", get_distance);

        printf("\n");
        sleep(1);
    }

    gpio_exit();

    return 0;
}
